<template>
	<view class="page">
		<view class="wrap">
			<!-- 上拉加载 -->
			<zb-table :columns="column" :data="datas" :stripe="true" :fit="false" :border="true"
				:show-header="true"></zb-table> <!-- :isShowLoadMore="true" :pullUpLoading="loadingData" -->
			<u-loadmore :status="status" :loadmoreText="loadmoreText"  @loadmore="loadmore"/>
		</view>
	</view>
</template>

<script>
	import {
		iplog
	} from '@/api/common.js';
	export default {
		data() {
			return {
				status: 'loadmore',
				loadmoreText: '点击加载更多',
				id: '',
				page: 0,
				pageCount: 10,
				column: [{
						name: 'ip',
						label: 'IP',
						fixed: false,
						width: 154,
						emptyString: '--'
					},
					{
						name: 'type',
						label: '类型',
						sorter: false,
						width: 60,
						align: 'right',
					},
					{
						name: 'time',
						label: '时间',
						width: 140,
						sorter: false
					}
				],
				datas: []
			}
		},
		onLoad: function(option) {
			console.log("onLoad:" + option.id)
			this.id = option.id
			this.iplog_one()
		},
		onReachBottom() {
			this.status = 'loading';
			console.log('触发上拉加载：' + this.status)
			this.page++;
			this.iplog_one();
		},
		methods: {
			iplog_one() {
				iplog({
					page: this.page,
					size: this.pageCount,
					siteid: this.id
				}).then(res => {
					console.log(res);
					if (res.length > 0) {
						this.datas.push.apply(this.datas, res);
					}
					if (res.hasNext == false) {
						this.status = 'nomore';
					}
				}).catch(err => {
					console.log(err);
					uni.showToast({
						title: err,
						icon: 'none'
					});
				})
			},
			loadmore(){
				console.log('触发加载：' + this.status)
				this.page++;
				this.iplog_one();
			}
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 24rpx;
	}
</style>